fix(exporter-otlp-proto-http): log response body on metric export failure#5159
Open
amir-h-rassafi wants to merge 1 commit intoopen-telemetry:mainfrom
Open
Conversation
…er error log When the OTLP HTTP metric exporter receives a non-2xx response, it currently logs only the HTTP status code and reason phrase (e.g. "400, Bad Request"), discarding the response body where the collector reports the actual rejection reason (payload too large, invalid attribute, unsupported content-type, etc.). This makes 4xx errors very hard to diagnose without patching the SDK or proxying traffic. Include the response body (truncated to 1024 chars) in the non-retryable failure log and in the retries-exhausted log so the collector's rejection detail is visible to users.
|
|
Contributor
|
Would #5155 resolve your issue ? Can you add your review to that PR ? |
Author
Thank you for having a look, Yes I think so but logic looks like not correct/helpful, left a comment https://github.com/open-telemetry/opentelemetry-python/pull/5155/changes#r3164122609 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The HTTP metric exporter logs only the status code and reason phrase on a non-2xx response, e.g.
400, Bad Request. The response body — where the collector explains why it rejected therequest (payload too large, invalid attribute, unsupported content-type, etc.) — is dropped. That makes 4xx errors hard to debug without patching the SDK or proxying traffic to the
collector.
This change captures
resp.text(truncated to 1024 chars) and includes it in the non-retryable failure log and the retries-exhausted log.Scope is metric exporter only. The trace and log HTTP exporters have the same gap; happy to follow up in a separate PR if this lands.
Fixes # (no linked issue — small log-only change, no behavior change beyond more verbose error output)
Type of change
How Has This Been Tested?
test_failure_logs_response_body— asserts the response body text appears in the error log on a 400.test_failure_logs_truncates_long_response_body— asserts bodies over 1024 chars are truncated with a...[truncated]marker.python -m pytest exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/— all tests pass except one pre-existing failure (test_aggregation_temporality, env leakage) thatalso fails on
mainwithout this change.ruff checkandruff format --checkclean. No new pylint warnings introduced.Does This PR Require a Contrib Repo Change?
Checklist:
Things to fix yourself before submitting
PR comment that this is a small log-output-only change with no behavior change.
metric exporter only" sentence are the most generic-sounding bits — easy targets to rewrite.